<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <script src="__STATIC__/js/common.js"></script>
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="#">基础管理</a>
        <a href="#">地区管理</a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.reload();" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" action="{:url('/region/index')}" method="get">
        <div class="layui-input-inline">
            <select name="city">
                <option>请选择</option>
                {foreach $province as $info}
                    <option value="{$info.id}">{$info.region_name}</option>
                {/foreach}
            </select>
        </div>
        <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
</div>
<xblock>
    <button class="layui-btn" onclick="province()"><i class="layui-icon"></i>开通省</button>
</xblock>
<table class="table table-bordered" style="width:60%">
    <tr>
        <th align="center" valign="middle" class="borderright">省</th>
        <th align="center" valign="middle" class="borderright">市</th>
        <th align="center" valign="middle" class="borderright">区</th>
    </tr>
    <tr>
        {foreach($data as $value)}
            <td >{$value.region_name}<span class="layui-icon layui-icon-add-1" onclick="city({$value.id})" title="添加">&#xe654;</span></td>
        {/foreach}
    </tr>
    <?php
        $where['parent_id'] = $value['id'];
        $where['region_type'] = 2;
        $where['is_pass'] = 1;
        $vals = model('region')->where($where)->field('id,parent_id,region_name,region_type,is_pass')->select();
    ?>
    {foreach $vals as $values}
        <tr>
            <td>
            </td>
            <td>
                {$values->region_name}<span class="layui-icon layui-icon-add-1" onclick="area({$values.id})" title="添加">&#xe654;</span>
                <hr/>
            </td>
            <?php
                $where['parent_id'] = $values['id'];
                $where['region_type'] = 3;
                $where['is_pass'] = 1;
                $datas = model('region')->where($where)->field('id,parent_id,region_name,region_type,is_pass')->select();
            ?>
            <td>
                {foreach $datas as $info}
                    <a href="{:url('/region/save')}?id={$info.id}">{$info->region_name}</a><br/>
                    <hr/>
                {/foreach}
            </td>
        </tr>
    {/foreach}
</table>
{$data->render()}
</body>
<script>
    //开通省
    function province(){
        window.location.href = "{:url('/region/province')}";
    }
    //开通市
    function city(id){
        window.location.href = "{:url('/region/city')}?id="+id;
    }
    //开通区/县
    function area(id){
        window.location.href = "{:url('/region/area')}?id="+id;
    }
</script>
</html>